package com.cuitrip.component.choicedialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.cuitrip.service.R;
import com.cuitrip.util.UIUtil;
import com.lab.adapter.BaseHolderView;
import com.lab.adapter.IAdapterData;


/**
 * Created by ak
 */
public class MultiItemHolderView extends BaseHolderView {

    private TextView mTvChoiceDialogItemTitle;

    private View mBottomLine;

    private Callback mCallback;

    public MultiItemHolderView(Context context) {
        super(context, R.layout.choice_dialog_item);
    }

    @Override
    public void initView(View rootView) {
        this.setClickable(true);
        mTvChoiceDialogItemTitle = UIUtil.findViewById(rootView, R.id.choice_dialog_item_title, TextView.class);
        mBottomLine = UIUtil.findViewById(rootView,R.id.bottom_line);
    }

    @Override
    public void bindData(final IAdapterData data, final int position) {
        if (null != data) {
            MultiItem multiItem = (MultiItem) data;
            mTvChoiceDialogItemTitle.setText(multiItem.getItemTitle());
            if (multiItem.getColor() != 0){
                mTvChoiceDialogItemTitle.setTextColor(multiItem.getColor());
            }
            this.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (null != mCallback) mCallback.onMultiItemClick(data, position);
                }
            });
        }
    }

    public void showBottomLine(boolean isShow){
        mBottomLine.setVisibility(isShow?VISIBLE:INVISIBLE);
    }

    public void setCallback(Callback callback) {
        this.mCallback = callback;
    }

    public interface Callback {
        void onMultiItemClick(IAdapterData data, int position);
    }

}
